package com.neusoft;

import javax.annotation.processing.Filer;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.Properties;
import java.util.Set;

public class DemoPropertisInputStream {

    public static void main(String[] args) throws Exception {
        //创建集合
        Properties props = new Properties();
        props.setProperty("name","zhangsan");
        props.setProperty("age","40");

        //创建输出流对象
        PrintWriter pw = new PrintWriter(new FileOutputStream("d:\\neusoft.txt"));
        //遍历集合并且写入到文件中
        Set<Object> objects = props.keySet();
        for (Object object : objects) {
            String key = (String)object;
            String value = (String) props.get(key);
            pw.println(key+"="+value);
        }

        pw.close();
    }
}
